<!-- 跟投收益记录 -->
<template>
    <div>
        <el-form :inline="true">
            <el-form-item label="跟投人名称：">
                <el-input v-model="searchName" placeholder="请输入跟投人员名称"></el-input>
            </el-form-item>
            <el-form-item >
                <el-button type="primary"  @click="searchList(1)" id="monitorEnter">查询</el-button>
            </el-form-item >
        </el-form>
        <table-list 
        :tableData='tableData'
        :tableInfos ='tableInfos'
        :tableChangeBtns='tableChangeBtns'
        :hasSera='true'
        >
        </table-list>
        <el-pagination
            layout="total, sizes, prev, pager, next, jumper"
            style="margin-top:30px"
            :current-page.sync="pageNum"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="pageSize"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :total="totalSize">
        </el-pagination>
    </div>
</template>
<script>
import api from '@/api/apiPath'
import tableList from './tableList'
export default {
    title:'跟投收益记录',
	components: {
        'table-list':tableList,
        },
	data () {
		return {
            searchName:'',
            
            tableInfos:[
                {label:'跟投人姓名',prop:'name'},
                {label:'工号',prop:'jobNumber'},
                {label:'职位',prop:'position'},
                {label:'部门',prop:'department'},
                {label:'业务线',prop:'businessLine'},
                {label:'累计跟投金额（元）',prop:'quota'},
                {label:'累计结算金额（元）',prop:'sumAmount'},
                {label:'实际累计分红（元）',prop:'amountBonus'},
                {label:'实际累计收益率',prop:'rateOfReturn'},
                {label:'更新时间',prop:'createTime'},
                {label:'操作',prop:'changeBtn'},
            ],
            tableChangeBtns:[
                {label:"查看",type:'view',fn:this.viewList},
                ],
            tableData:[],
            pageNum: 1,
            pageSize: 10,//每页几条
            totalSize: 0,
        }
    },
    methods:{
       
        //新增查看编辑
        viewList(type,idx){
            let insideId;
            //if(type != 'add')  insideId= this.tableData[idx].id;
            this.$router.push({path: '/viewProfit', query: {row:this.tableData[idx]}})
            
            },
        
        searchList(pageNum){
            let param = {
              pageNum:pageNum||this.pageNum,
              pageSize:this.pageSize,
              name:this.searchName,
            };
            this.axios.post(api.getInvestmentProfitList, param).then(res => {
                if (res.data.code == 200) {
                    let lists = res.data.data.list || [];
                    lists.forEach( list=> {
                       let {amountBonus=0,quota=1} = list;
                        list.rateOfReturn = parseFloat((amountBonus/quota*100).toFixed(2)) + '%'
                    });
                    this.tableData = lists;
                    this.totalSize = res.data.data.total;
                }
            })
            
        },
        handleCurrentChange () {
            this.searchList()
		},
		handleSizeChange (val) {
			this.pageSize = val
			this.searchList(1)
		},
	},
	created () {
        this.searchList();
    },
    activated(){
        this.searchList(1);
    },
	destroyed() {
		
	},
	filters: {

	}
}

</script>

<style lang="stylus" scoped>


</style>
